package com.fingard.dsp.bank.directbank.weixin01;

import com.fingard.dsp.bank.directConfig.ActSetItem;
import com.fingard.dsp.bank.directbank.bankInterface.IGetAppID;
import com.fingard.dsp.bank.reqrespobj.getappid.ReqQueryGetAppId;
import com.fingard.dsp.bank.reqrespobj.getappid.RetAtsQueryGetAppId;
import com.fingard.text.StringHelper;

public class WEIXIN01GetAppId extends WEIXIN01Base implements IGetAppID {
    @Override
    public RetAtsQueryGetAppId queryGetAppId(ReqQueryGetAppId p_reqQry) throws Exception {
        RetAtsQueryGetAppId retAts = new RetAtsQueryGetAppId(p_reqQry);
        retAts.rdSeq = p_reqQry.rdSeq;
        try {
            ActSetItem actItem = getBankConfig().getActSetItem(p_reqQry.ownAct, "unifiedorder");
            if (actItem != null) {
                if (StringHelper.hasAnyChar(actItem.appId)) {
                    retAts.respCode = "0";
                    retAts.respInfo = "AppId读取成功！";
                    retAts.appId = actItem.appId;
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = "账号:[" + p_reqQry.ownAct + "]商户的配置信息中'appId'配置为空,请检查'config/portfiles/" + p_reqQry.reqHeader.bankCode + "/config.xml'中该账号相关商户配置节点是否配置正确!";
                }
            } else {
                retAts.respCode = "-1";
                retAts.respInfo = "未找到账号:[" + p_reqQry.ownAct + "]商户配置信息!";
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            retAts.respCode = "-1";
            retAts.respInfo = ex.getMessage();
            WriteBankLogLn(ex);
        }
        return retAts;
    }
}
